﻿@{
    ViewBag.Title = "Add";
    Layout = "~/Areas/Admin/Views/Shared/_Layout.cshtml";
}
@model UserModel
<div style="text-align: center; color: red">@TempData["Result"]</div>
<div class="row-fluid" style="margin-top: 10px; margin-bottom: 50px;">
    <div class="span24 span-first">
        <form id="AddForm" class="form-horizontal" method="post" action="/Admin/UserManage/AddUser">
            @Html.HiddenFor(x => x.Entity.ID)
            @Html.AntiForgeryToken()
            <h3 style="margin-left: 20px">基本信息</h3>
            <div class="control-group">
                <label class="control-label"><s>*</s>用户名称：</label>
                <div class="controls">
                    @Html.TextBoxFor(x => x.Entity.UserName, new { style = "width:150px" })
                </div>
            </div>
            <div class="control-group">
                <label class="control-label"><s>*</s>密码：</label>
                <div class="controls">
                    @Html.TextBoxFor(x => x.Entity.Password, new { style = "width:150px" })
                </div>
            </div>
            <div class="control-group">
                <label class="control-label"><s>*</s>确认密码：</label>
                <div class="controls">
                    @Html.TextBoxFor(x => x.Entity.ConfirmPassword, new { style = "width:150px" })
                </div>
            </div>
            <div class="control-group">
                <label class="control-label"><s>*</s>角色：</label>
                <div class="controls">
                    <div id="Roles">
                        @Html.HiddenFor(x => x.Entity.Roles)
                    </div>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">昵称：</label>
                <div class="controls">
                    @Html.TextBoxFor(x => x.Entity.Name, new { style = "width:150px" })
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">电子邮件：</label>
                <div class="controls">
                    @Html.TextBoxFor(x => x.Entity.Email, new { style = "width:450px" })
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">积分：</label>
                <div class="controls">
                    @Html.TextBoxFor(x => x.Entity.Integral, new { style = "width:150px" })
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">状态：</label>
                <div class="controls">
                    <label>@Html.RadioButtonFor(x => x.Entity.Status, "10", new { @checked = "checked" }) 正常</label>
                    <label>@Html.RadioButtonFor(x => x.Entity.Status, "20") 禁用</label>
                </div>
            </div>
            <h3 style="margin-left: 20px">更多信息</h3>
            <div class="control-group">
                <label class="control-label">头像：</label>
                <div class="controls">
                    @Html.TextBoxFor(x => x.EntityInfo.Photo)
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">真实姓名：</label>
                <div class="controls">
                    @Html.TextBoxFor(x => x.EntityInfo.RealName)
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">性别：</label>
                <div class="controls">
                    <label>@Html.RadioButtonFor(x => x.EntityInfo.Gender, "True", new { @checked = "checked" }) 男</label>
                    <label>@Html.RadioButtonFor(x => x.EntityInfo.Gender, "False") 女</label>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">生日：</label>
                <div class="controls">
                    @Html.TextBoxFor(x => x.EntityInfo.Birthday, new { @class = "calendar", style = "width:140px" })
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">移动电话：</label>
                <div class="controls">
                    @Html.TextBoxFor(x => x.EntityInfo.Phone)
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">固定电话：</label>
                <div class="controls">
                    @Html.TextBoxFor(x => x.EntityInfo.Tel)
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">QQ：</label>
                <div class="controls">
                    @Html.TextBoxFor(x => x.EntityInfo.QQ)
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">地区：</label>
                <div class="controls">
                    <div id="Province" style="width: 150px; float: left; overflow: auto">
                        @Html.HiddenFor(x => x.EntityInfo.Province)
                    </div>
                    <div id="City" style="width: 150px; float: left; margin-left: 5px">
                        @Html.HiddenFor(x => x.EntityInfo.City)
                    </div>
                    <div id="County" style="width: 150px; float: left; margin-left: 5px">
                        @Html.HiddenFor(x => x.EntityInfo.County)
                    </div>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">街道：</label>
                <div class="controls">
                    @Html.TextBoxFor(x => x.EntityInfo.Address, new { style = "width:450px" })
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">邮编：</label>
                <div class="controls">
                    @Html.TextBoxFor(x => x.EntityInfo.PostCode)
                </div>
            </div>
            <div class="control-group">
                <label class="control-label" style="height: 80px">简介：</label>
                <div class="controls" style="height: 80px">
                    @Html.TextAreaFor(x => x.EntityInfo.Introduction, new { style = "width:450px;height:60px" })
                </div>
            </div>
            <hr>
            <div style="text-align: center">
                <button class="button button-primary" id="submitBtn" type="submit">提交</button>
                <button class="button" type="reset" onclick="parent.CloseWin()">取消</button>
            </div>
        </form>
    </div>
</div>
<script type="text/javascript">
    var Select = BUI.Select;
    var data = eval('@Html.Raw(Model.RoleList)');
    var data1 = eval('@Html.Raw(Model.ProvinceList)');
    var data2 = eval('@Html.Raw(Model.CityList)');
    var data3 = eval('@Html.Raw(Model.CountyList)');
    var select = new Select.Select({
        render: '#Roles',
        value: "",
        width: '460',
        items: data,
        multipleSelect: true,
        //forceFit: false, //不强迫列表跟选择器宽度一致
        valueField: '#Entity_Roles'
    });
    select.render();
    //省
    var select1 = new Select.Select({
        render: '#Province',
        width: '150',
        items: data1,
        //multipleSelect: true,
        //forceFit: false, //不强迫列表跟选择器宽度一致
        valueField: '#EntityInfo_Province'
    });
    select1.render();
    //市
    var store2 = new BUI.Data.Store({
        url: '/WebApi/GetZoneByParentID'
    });
    var select2 = new Select.Select({
        render: '#City',
        width: '150',
        //items: data2,
        store: store2,
        //multipleSelect: true,
        //forceFit: false, //不强迫列表跟选择器宽度一致
        valueField: '#EntityInfo_City'
    });
    select2.render();
    //县
    var store3 = new BUI.Data.Store({
        url: '/WebApi/GetZoneByParentID'
    });
    var select3 = new Select.Select({
        render: '#County',
        width: '150',
        store: store3,
        //items: data3,
        //multipleSelect: true,
        //forceFit: false, //不强迫列表跟选择器宽度一致
        valueField: '#EntityInfo_County'
    });
    select3.render();

    select1.on('change', function (ev) {
        store2.load({ id: ev.value });
        select2.setSelectedValue('');
        select3.removeChildren();
        select3.setSelectedValue('');
    });
    select2.on('change', function (ev) {
        store3.load({ id: ev.value });
        select3.setSelectedValue('');
    });


    //日期控件
    BUI.use('bui/calendar', function (Calendar) {
        var datepicker = new Calendar.DatePicker({
            trigger: '.calendar',
            //showTime: true,
            //maxDate: '2014-01-01',
            //minDate: '2013-7-25',
            autoRender: true
        });
    });
</script>
